import os
import sys

from core.rest_client import RestClient
from common.read_data import data

BASE_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(BASE_PATH)

data_file_path = os.path.join(BASE_PATH, "config", "setting.ini")
api_root_url = data.load_ini(data_file_path)["host"]["api_root_url"]


class Template(RestClient):
    '''
    模板接口的url定义类
    '''

    def __init__(self, api_root_url, **kwargs):
        super(Template, self).__init__(api_root_url, **kwargs)

    def list(self, **kwargs):
        '''
        获取所有的模板
        '''
        return self.get("/api/template/list", **kwargs)


    def info(self,**kwargs):
        '''
        获取模板信息
        '''
        return self.get("/api/template/info", **kwargs)

    def create(self, **kwargs):
        '''
        创建模板
        '''
        return self.post("/api/template/create", **kwargs)

    def modify(self, **kwargs):
        '''
        修改用户分组
        '''
        return self.post("/api/group/modify", **kwargs)


template = Template(api_root_url)